package Share;

import java.io.DataOutputStream;
import java.io.IOException;
import java.security.PrivateKey;
import java.security.SignatureException;


public class SecureDataOutputStream extends DataOutputStream {
	private SecureOutputStream stream;
	
	public SecureDataOutputStream(SecureOutputStream stream) {
		super(stream);
		this.stream = stream;
	}
	
	public SecureOutputStream getStream()
	{
		return stream;
	}
	
	public void startHash()
	{
		stream.startHash();
	}
	
	public void writeHash() throws IOException
	{
		stream.writeHash();
	}
	
	public void writeSignature(PrivateKey key) throws SignatureException, IOException
	{
		Util.write(this, Util.signData(stream.getHash(), key));
	}
}
